<?php

use yii\helpers\Url;
use yii\helpers\Html;
use website\helpers\Render;
use common\models\User;
use common\models\Design;
use common\models\Recruit;
use common\models\RecruitApplicant;

$this->addCrumbs('招聘管理', 'employer/recruit');
$this->title = '投递列表';
?>
<style>
    #info-table td {padding:10px;}
    #info-table td .status .flyer-status {margin-right:0 !important;}
    #info-table td .imager {width:110px;height:110px;border-radius:100%;}
</style>

<div class="contenter">
    <?= $this->render('/user/navigator', ['active' => 'recruit-list']) ?>
    
    <div id="user-contenter">
        <div class="box-shadow pb-20px" id="sub-contenter">
            <div class="data-title"><span class="h3"><?= $this->title ?></span></div>
            <div class="data-content search flyer-form mt-10px" id="info-search">
                <div class="form-item">
                    <div class="input-title">招聘标题：</div>
                    <div class="input-inline input-mid fs"><?= $recruit->title ?></div>
                </div>
                <div class="form-item">
                    <div class="item-inline">
                        <div class="input-title">发布日期：</div>
                        <div class="input-inline input-mid fs"><?= date('Y-m-d', $recruit->created_at) ?></div>
                    </div>
                    <div class="item-inline ml-20px">
                        <div class="input-title">状态：</div>
                        <div class="input-inline input-mid fs"><?= Render::show(Recruit::$statusSelector, $recruit->status) ?></div>
                    </div>
                    <div class="item-inline" style="display:none;">
                        <?= Render::select('style', Design::$styleSelector, null) ?>
                        <?= Render::select('status', RecruitApplicant::$statusSelector, null) ?>
                        <?= Render::select('work_life', User::$workLifeSelector, null) ?>
                        <?= Render::select('gender', User::$genderSelector, null) ?>
                        <select id="category"></select>
                    </div>
                </div>
            </div>
            <div class="flyer-table fat simple">
                <table id="info-table" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr><td colspan="3"><i class="icon-search"></i> 数据加载中，请稍后.</td></tr>
                    </tbody>
                </table>
            </div>
            <div class="flyer-page mt right" id="info-page">
                <div class="html mr-10px"></div>
            </div>
        </div>
    </div>
</div>

<script src="<?= Render::static('art-template/template.js') ?>"></script>
<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tabler.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tableHandler.class.js') ?>"></script>
<script src="<?= Render::static('flyer/categorier.class.js') ?>"></script>
<script src="<?= Render::static('system/category-design.data.js') ?>"></script>
<script>
    var categorierClass = new categorier();
    $(document).ready(function() {
        categorierClass.init({ fix: false, dom: '#category', data: DesignCategories, relate: DesignCategoriesRelation, start: '<?= Yii::$app->params['designCategories'] ?>' });
        // 初始化表格异步加载事件
        (new tabler).init({
            // 请求地址
            url: '<?= Url::to('@web/employer/recruit-applicant?id='.$recruit->id) ?>',
            // 数据渲染配置
            table: '#info-table', page: '#info-page', template: 'info-template', search: '#info-search', readyCall: true,
            // param => tabler
            afterPost: function(param) {
                // 名称显示
                var renderList = { gender: 'sex', work_life: 'work-life', type: 'type', status: 'status', style: 'styles', default: '--' };
                for(var css in renderList) {
                    tableHandler.renderCategory({ category: $(param.tabler).find('.' + renderList[css]), select: css, default: '--' });
                }
                tableHandler.renderCategory({ category: $(param.tabler).find('.categories'), default: '--', functionName: function(id) {
                    return categorierClass.renderTitles(id);
                }});
            }
        });
    });
</script>
<script id="info-template" type="text/html">
    {{if infos != undefined && infos.length}}
    {{each infos as info key}}
    <tr id="tr-{{info.id}}" data-id="{{info.id}}">
        <td class="first tac w-130px"><img class="imager mt-10px" src="<?= Render::upload('{{designer[info.designer_id].photo}}') ?>"></td>
        <td>
            <p>{{designer[info.designer_id].nickname}}（{{"**"+designer[info.designer_id].realname.slice(-1)}}）</p>
            <p>
                <span class="sex">{{designer[info.designer_id].gender}}</span> · 
                <span class="work-life">{{designer[info.designer_id].work_life}}</span> · {{designer[info.designer_id].salary / 100 | fmoney}}<i class="icon-cny"></i>
            </p>
            <p>综合评价：<span class="star cl-red">{{designer[info.designer_id].star | star}}</span></p>
            <p>
                <span>擅长风格：<span class="styles">{{designer[info.designer_id].stylesString}}</span></span>
                <span class="ml-20px">擅长类目：<span class="categories">{{designer[info.designer_id].categoriesString}}</span></span>
            </p>
            <p>擅长软件：{{designer[info.designer_id].skills}}</p>
        </td>
        <td class="tar w-200px">
            <p>投递时间：{{info.created_at | dateShow: format = 'minutes'}}</p>
            <p>投递状态：<span class="status">{{info.status}}</span></p>
            <p>
                <a class="flyer-button normal border-round narrow thin" href="<?= Url::to('@web/seer/resume?id=') ?>{{info.designer_id}}" target="_blank"><i class="icon-eye-open"></i> 查看简历</a>
                {{if info.status == '<?= RecruitApplicant::StatusExamine ?>'}}
                <!--a class="flyer-button normal border-round narrow thin refuse-data"><i class="icon-comment"></i> 拒绝</a-->
                <a class="flyer-button normal border-round narrow thin" href="<?= Url::to('@web/employer/employment?designer_id=') ?>{{info.designer_id}}"><i class="icon-ok"></i> 雇佣</a>
                {{/if}}
            </p>
        </td>
    </tr>
    {{/each}}
    {{else}}
    <tr>
        <td class="first" colspan="3"><i class="icon-ban-circle"></i> 暂时还没有任何设计师投递简历！</td>
    </tr>
    {{/if}}
</script>